/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.charlie.sessions;

import com.charlie.beans.Roles;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Вова
 */
@Stateless
public class RolesFacade extends AbstractFacade<Roles> implements RolesFacadeLocal {
    @PersistenceContext(unitName = "CharlieShop-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public RolesFacade() {
        super(Roles.class);
    }

    @Override
    public Roles findByRolesName(String name) {
        try {
            return (Roles) em.createNamedQuery("Roles.findByRolesName").setParameter("rolesName", name).getSingleResult();
        } catch(NoResultException ex) {
            return null;
        }
    }
    
}
